package com.zry.android.config;


import com.zry.android.handler.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Zry
 */

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    // 把LoginInterceptor放入ioc容器中
    @Bean
    public LoginInterceptor getLoginInterceptor(){
        return new LoginInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getLoginInterceptor())
                // 以下路由都会被拦截器拦截
                .addPathPatterns("/api/**")
                .excludePathPatterns("/api/sys/**");
    }


}
